package com.controller;

import com.api.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;
    /**
     * ⽣生成验证码并发送到对应邮箱，成功true，失败false
     * @param email
     * @return
     */
    @GetMapping("/create/{email}")
    public boolean create(@PathVariable String email) {
        return codeService.create(email);
    }

    /**
     * 校验验证码是否正确，0正确1错误2超时
     * @param email
     * @return 0/1/2
     */
    @GetMapping("/validate/{email}/{code}")
    public boolean validate(@PathVariable String email,@PathVariable String code) {
        return codeService.validate(email,code);
    }

}
